﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HRM.Models;

namespace HRM.Controllers
{
    public class DotDkController : Controller
    {
        private HRMTTNS41Context db = new HRMTTNS41Context();

        //
        // GET: /DotDk/

        public ActionResult Index()
        {
            var dotdk_tk = db.DotDK_TK;
            return View(dotdk_tk.ToList());
        }

        //
        // GET: /DotDk/Details/5

        public ActionResult Details(string id = null)
        {
            DotDK_TK dotdk_tk = db.DotDK_TK.Find(id);
            if (dotdk_tk == null)
            {
                return HttpNotFound();
            }
            return View(dotdk_tk);
        }

        //
        // GET: /DotDk/Create

        public ActionResult Create()
        {
            //ViewBag.MaNV = new SelectList(db.NhanViens, "MaNV", "HoTen");
            return View();
        }

        //
        // POST: /DotDk/Create

        [HttpPost]
        public ActionResult Create(DotDK_TK dotdk_tk)
        {
            if (ModelState.IsValid)
            {
                db.DotDK_TK.Add(dotdk_tk);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

           // ViewBag.MaNV = new SelectList(db.NhanViens, "MaNV", "HoTen", dotdk_tk.MaNV);
            return View(dotdk_tk);
        }

        //
        // GET: /DotDk/Edit/5

        public ActionResult Edit(string id = null)
        {
            DotDK_TK dotdk_tk = db.DotDK_TK.Find(id);
            if (dotdk_tk == null)
            {
                return HttpNotFound();
            }
            //ViewBag.MaNV = new SelectList(db.NhanViens, "MaNV", "HoTen", dotdk_tk.MaNV);
            return View(dotdk_tk);
        }

        //
        // POST: /DotDk/Edit/5

        [HttpPost]
        public ActionResult Edit(DotDK_TK dotdk_tk)
        {
            if (ModelState.IsValid)
            {
                db.Entry(dotdk_tk).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
           // ViewBag.MaNV = new SelectList(db.NhanViens, "MaNV", "HoTen", dotdk_tk.MaNV);
            return View(dotdk_tk);
        }

        //
        // GET: /DotDk/Delete/5

        public ActionResult Delete(string id = null)
        {
            DotDK_TK dotdk_tk = db.DotDK_TK.Find(id);
            if (dotdk_tk == null)
            {
                return HttpNotFound();
            }
            return View(dotdk_tk);
        }

        //
        // POST: /DotDk/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(string id)
        {
            DotDK_TK dotdk_tk = db.DotDK_TK.Find(id);
            db.DotDK_TK.Remove(dotdk_tk);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}